package com.example.administrator.appstpremvpdemo.presenter;

import com.example.administrator.appstpremvpdemo.contract.HomefragentContract;
import com.example.administrator.appstpremvpdemo.model.HomefragentModel;

import java.util.HashMap;
import java.util.List;

/**
 * @Author Administrator
 * @Date 2017/12/25
 * @description
 * @function
 */

public class HomefragentPresenter<T> implements HomefragentContract.Presenter<T> {

    HomefragentContract.View mView;
    HomefragentModel mModel;

    public HomefragentPresenter(HomefragentContract.View view, String url) {
        this.mView = view;
        this.mModel = new HomefragentModel(this, url);
    }

    @Override
    public void start() {
        mModel.start();
    }

    @Override
    public void destroy() {
        mModel.destroy();
    }

    /**
     * 这里通常是对用户给的请求参数进行处理，处理完成后传给model
     * @param parms
     */
    public void setRequestParms(HashMap<String ,String> parms) {
        mModel.setRequestParms(parms);
    }

    /**
     * 调用view显示数据
     * @param list
     */
    @Override
    public void showList(List<T> list) {
        mView.onLoadSuccess(list);
    }

    @Override
    public void pullLoadMore() {
        mModel.requestPullLoadMoreData();
    }
}
